package com.hsj.springai.controller;

import com.hsj.springai.config.AService;
import com.hsj.springai.config.MethodLog;
import jakarta.annotation.Resource;
import org.springframework.ai.openai.OpenAiChatModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class AiController {

    @Autowired
    private OpenAiChatModel aiChatModel;
    @Resource
    private AService aService;
    @GetMapping("/ai/embedding")
    public String embed(@RequestParam(value = "message", defaultValue = "tell me  a joke ") String message) {
        return aiChatModel.call(message);
    }

    @GetMapping("/test/aspect/{id}")
    @MethodLog
    public void test(@PathVariable("id")String id){
        aService.pay(id);
    }
}
